<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('栏目列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="dept-form">
                <div class="select-list">
                    <ul>
                        <li>
                            栏目名称：<input type="text" name="columnName"/>
                        </li>
                        <li>
                            <a class="btn btn-success btn-rounded btn-sm" onclick="$.treeTable.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-success btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="add()" shiro:hasPermission="'cms:column:add'">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="'cms:column:edit'">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-success" id="expandAllBtn">
                <i class="fa fa-exchange"></i> 展开/折叠
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <input type="hidden" id="columnId" name="columnId" value="0">
            <table id="bootstrap-tree-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('cms:column:edit')}]];
    var removeFlag = [[${@permission.hasPermi('cms:column:remove')}]];
    var datas = [[${@dict.getType('cms_show_hide')}]];
    var datas2 = [[${@dict.getType('cms_yes_no')}]];
    var prefix = ctx + "cms/column"
    $(function () {
        var options = {
            code: "id",
            parentCode: "pId",
            uniqueId: "id",
            expandAll: true,
            expandFirst: false,
            url: prefix + "/columnList",
            createUrl: prefix + "/add?id={id}",
            updateUrl: prefix + "/edit?columnId={id}",
            removeUrl: prefix + "/remove?columnId={id}",
            modalName: "栏目",
            columns: [{
                field: 'selectItem',
                radio: true
            },
                {
                    field: 'name',
                    title: '栏目名称',
                    align: "left"
                },
                {
                    field: 'columnFlag',
                    title: '栏目标识',
                    align: "left"
                },
                {
                    field: 'siteName',
                    title: '所属站点',
                    align: "left"
                },
                {
                    field: 'outLink',
                    title: '是否外部链接',
                    align: "left",
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas2, row.outLink);
                    }
                },
                {
                    field: 'href',
                    title: '外部访问路径',
                    align: "left",
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'display',
                    title: '状态',
                    align: "left",
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, row.display);
                    }
                },
                {
                    field: 'sort',
                    title: '排序',
                    align: "left"
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    align: "left"
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    align: "left"
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.pId != 0) {
                            actions.push('<a class="btn btn-success  btn-xs" href="javascript:void(0)" onclick="$.operate.add(\'' + row.id + '\')"><i class="fa fa-plus"></i>新增</a> ');
                            actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-trash"></i>删除</a>');
                            return actions.join('');
                        } else {
                            actions.push('<a class="btn btn-success  btn-xs" href="javascript:void(0)" onclick="$.operate.add(\'' + row.id + '\')"><i class="fa fa-plus"></i>新增</a> ');
                            return actions.join('');
                        }
                    }
                }]
        };
        $.treeTable.init(options);
    });

    //新增
    function add(){
        var columnId=$("#columnId").val();
        $.operate.add(columnId);
    }
</script>
</body>
</html>